// pages/home/examine/examine.js
const globalIp = getApp().globalData.userIp
Page({
  /**
   * 页面的初始数据
   */
  data: {
    info: "",
    pageIndex:1,
    pageSize:8,
    total: 0,
    list: []
  },

  getInputValue:function(e) {
    this.setData({
      info: e.detail.value
    })
  },

  selectData: function(){
    this.getProject();
  },

  trueIndex: function(e){
    wx.navigateTo({
      url: '../examineindex/examineindex?LineNum='+e.currentTarget.dataset.num+'&tie=2',
    })
  },

  // 统一请求
  getProject: function() {
    let that = this;
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    var length = 0;
    wx.request({
      url: globalIp + 'home/queryBusinessUser',
      data: {
        userName: that.data.info || '',
        openId: that.data.openId || wx.getStorageSync('userInfo').openid,
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (res.data.jsonObject) {
          that.setData({
            list: res.data.jsonObject
          })
        } 
      },
      fail: function(res) {
        wx.showToast({
          title: '请返回上一页面，重新请求',
          icon: 'none',
          duration: 2000,
        })
      },
      complete: function(res) {
        setTimeout(() => {
          wx.hideLoading()
        }, 15 * length)
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // this.getProject();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getProject();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  }
})